package com.zut.base.common.entry;

import lombok.Data;

import java.io.Serializable;

/**
 * @author zhang
 * @date 2020/11/1 13:41
 */
@Data
public class ResultVO<T> implements Serializable {
    /**
     * 状态码，比如100代表响应成功
     */
    private int code;
    /**
     * 响应信息，用来说明响应情况
     */
    private String msg;
    /**
     * 响应的具体数据
     */
    private T data;

    public ResultVO(T data) {
        this(ResultCode.SUCCESS, data);
    }

    public ResultVO(ResultCode resultCode, T data) {
        this.code = resultCode.getCode();
        this.msg = resultCode.getMsg();
        this.data = data;
    }
    public ResultVO set(ResultCode resultCode, T data) {
        this.code = resultCode.getCode();
        this.msg = resultCode.getMsg();
        this.data = data;
        return this;
    }
    public ResultVO(int code,String msg) {
        this.code = code;
        this.msg = msg;
    }
    public ResultVO(int code,String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ResultVO() {

    }

    public String getMsg() {
        return msg;
    }

    public int getCode() {
        return code;
    }

    public T getData() {
        return data;
    }
}
